<?php
defined('IN_ADMIN') or exit('No permission resources.');
$show_validator = $show_scroll = $show_dialog = 1;
include $this->admin_tpl('header', 'admin');
?>
<form method="post" action="?m=<?php echo ROUTE_M;?>&c=<?php echo ROUTE_C;?>&a=<?php echo ROUTE_A;?>" id="myform" onsubmit="return check_must()">
	<div class="pad-10">
	<div class="col-tab">
	<ul class="tabBut cu-li">
		<li id="tab_info_1" class="on" onclick="SwapTab('info','on','',6,1);"><?php echo L('basic_info', '', 'admin');?></li>
		<li id="tab_info_2" onclick="SwapTab('info','on','',6,2);"><?php echo L('extend_info')?></li>
	</ul>
		<div class="col-tab">
			<div id="div_info_1" class="contentList pad-10">
				<table width="100%" class="table_form ">
					<tbody>
						<tr>
							<th width="200"><?php echo L('name')?>：</th>
							<td><input name="talent[name]" id="realname" class="input-text" type="text" size="40"></td>
						</tr>
						<tr>
							<th width="200"><?php echo L('name_letter')?>：</th>
							<td><input name="talent[name_letter]" id="name_letter" class="input-text" type="text" size="40" placeholder="姓名全拼正确写法请参考如下示例..."></td>
						</tr>
						<tr>
							<th width="200"><span style="color:red;font-weight: bold;"><?php echo L('name_letter_reminder')?>：</span></th>
							<td>
							     <img alt="" style="width:350px;height:200px;" src="http://m.nsr.com.cn/resource/uploadfile/images/2017/0830/20170830091731350.png">
							</td>
						</tr>
						<tr>
							<th width="200"><?php echo L('identification')?>：</th>
							<td><input name="talent[identification]" id="identification" class="input-text" type="text" size="40"></td>
						</tr>
						<tr>
							<th width="200"><?php echo L('first_letter')?>：</th>
							<td><input name="talent[first_letter]" id="first_letter" class="input-text" type="text" size="40"></td>
						</tr>
						<tr>
							<th width="200"><?php echo L('student_gender')?>：</th>
							<td><?php echo form::radio(array('1'=>L('boy'),'2'=>L('girl')),'1','name="talent[gender]"')?></td>
						</tr>
						<tr>
							<th width="200"><?php echo L('train_level')?>：</th>
							<td>
							<select name="talent[train_level]" id="train_level">
								<option value="" selected="">请选择学级</option>
								<?php foreach($this->train_level as $k=>$v){?>
								<option value="<?php echo $v;?>" ><?php echo $v;?></option>
								<?php }?>
								</select></td>
						</tr>
						<tr>
							<th width="200"><?php echo L('train_type')?>：</th>
							<td>
							<select name="talent[train_type]" id="train_type">
								<option value="" selected="">请选择学类</option>
								<?php foreach($this->train_type as $k=>$v){?>
								<option value="<?php echo $v;?>" ><?php echo $v;?></option>
								<?php }?>
								</select></td>
						</tr>
						<tr>
							<th width="200"><?php echo L('train_rank')?>：</th>
							<td>
							 <select name="talent[train_rank]" id="train_rank">
								<option value="" selected="">请选择学期</option>
								<?php foreach($this->train_rank as $k=>$v){?>
								<option value="<?php echo $v;?>" ><?php echo $v;?></option>
								<?php }?>
								</select>
							</td>
						</tr>
						<tr>
							<th width="200"><?php echo L('train_rank_range')?>：</th>
							<td>
							 <?php echo form::date('talent[start_time]','',0,0,'false');?>- &nbsp;<?php echo form::date('talent[end_time]','',0,0,'false');?>
							</td>
						</tr>
						<tr>
							<th width="200"><?php echo L('train_result')?>：</th>
							<td>
							 <select name="talent[train_result]" id="train_result">
								<option value="" selected="">请选择成绩</option>
								<?php foreach($this->train_result as $k=>$v){?>
								<option value="<?php echo $v;?>" ><?php echo $v;?></option>
								<?php }?>
								</select>
							</td>
						</tr>
						<tr>
							<th width="200"><?php echo L('train_school')?>：</th>
							<td>
							 <select name="talent[train_school]" id="train_school">
								<option value="" selected="">请选择校区</option>
								<?php foreach($this->train_school as $k=>$v){?>
								<option value="<?php echo $v;?>" ><?php echo $v;?></option>
								<?php }?>
								</select>
							</td>
						</tr>
						<tr>
							<th width="200"><?php echo L('train_year')?>：</th>
							<td>
							 <select name="talent[train_year]" id="train_year">
								<option value="" selected="">请选择校区</option>
								<?php foreach($this->train_year as $k=>$v){?>
								<option value="<?php echo $v;?>" ><?php echo $v;?></option>
								<?php }?>
								</select>&nbsp;&nbsp;&nbsp;<font color="red">提示：默认为<?php echo date('Y',time())?>年！</font>
							</td>
						</tr>
						<tr>
							<th width="200"><?php echo L('height')?>：</th>
							<td><input name="talent[height]" class="input-text" type="text" id="height" size="40"><font color="red">&nbsp;&nbsp;&nbsp;提示：请输入身高，如身高为183cm，直接输入183即可</font></td>
						</tr>
						<tr>
							<th width="200"><?php echo L('profession')?>：</th>
							<td><input name="talent[profession]" class="input-text" type="text" size="40"></td>
						</tr>
						<tr>
							<th><?php echo L('certificate_pic')?>：</th>
							<td><?php echo form::images('talent[certificate_pic]', 'certificate_pic', '', 'student', '', 40)?></td>
						</tr>
					</tbody>
				</table>
			</div>
			<div id="div_info_2" class="contentList pad-10 hidden">
				<table width="100%" class="table_form ">
						<tr>
							<th><?php echo L('image_home')?>：</th>
							<td><?php echo form::images('talent[image_home]', 'image_home', '', 'student', '', 40)?></td>
						</tr>
						<tr>
							<th width="200"><?php echo L('award_history')?>：</th>
							<td><textarea name="talent[award_history]" id="award_history"></textarea><?php echo form::editor('award_history','full','','','',1,1,'',800,300)?></td>
						</tr>
						<tr>
							<th width="200"><?php echo L('contest_history')?>：</th>
							<td><textarea name="talent[contest_history]" id="contest_history"></textarea><?php echo form::editor('contest_history','full','','','',1,1,'',800,300)?></td>
						</tr>
						<tr>
							<th width="200"><?php echo L('perform_history')?>：</th>
							<td><textarea name="talent[perform_history]" id="perform_history"></textarea><?php echo form::editor('perform_history','full','','','',1,1,'',800,300)?></td>
						</tr>
						<tr>
							<th width="200"><?php echo L('thoughts')?>：</th>
							<td><textarea name="talent[thoughts]" id="thoughts"></textarea><?php echo form::editor('thoughts','full','','','',1,1,'',800,200)?></td>
						</tr>
				</table>
			</div>
			<div class="bk15"></div>
			<?php if($action_source=="course_nsr_student"){ ?><input type="hidden" name="course_id" value="<?= $course_id?>"><?php }?>
			<input name="dosubmit" type="submit"   <?php if($action_source=="course_nsr_student"){ ?>class="dialog "  <?php }else{ ?>class="button" <?php }?>id="dosubmit"  value="<?php echo L('submit')?>" >
		</div>
	</div>
</div>
</form>
</body>
</html>
<script type="text/javascript">
function check_must(){
	var train_school = $("#train_school").val();
	var train_type = $("#train_type").val();
	var name_letter = $("#name_letter").val();
	var start_time = $("#start_time").val();
	var end_time = $("#end_time").val();
	var train_result = $("#train_result").val();
	if(train_school==''){
	    alert('请选择校区');
		return false;
	}
	if(train_type==''){
	    alert('请选择类别');
		return false;
	}
	if(name_letter==''){
	    alert('请输入姓名全拼');
		return false;
	}
	if(start_time==''){
	    alert('请选择学期开始时间');
		return false;
	}
	if(end_time==''){
	    alert('请选择学期结束时间');
		return false;
	}
	if(train_result==''){
	    alert('请选择成绩');
		return false;
	}
}
function SwapTab(name,cls_show,cls_hide,cnt,cur){
	for(i=1;i<=cnt;i++){
		if(i==cur){
			 $('#div_'+name+'_'+i).show();
			 $('#tab_'+name+'_'+i).attr('class',cls_show);
		}else{
			 $('#div_'+name+'_'+i).hide();
			 $('#tab_'+name+'_'+i).attr('class',cls_hide);
		}
	}
}
//校验手机号
function isTel(tel){
	if(!(/^1(3[0-9]|5[012356789]|8[0-9]|4[7]|7[678])\d{8}$/.test(tel))) return "请输入正确的手机号";
	return true;
}

//校验真实姓名
function isRealname(realname){
	if(!(/^[\u4e00-\u9fa5]{2,4}$/i.test(realname))) return "请填写真实姓名";
	return true;
}

//校验邮箱
function isEmail(email){
	if(!(/^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/.test(email))) return "请输入正确的邮箱";
	return true;
}

//校验大写字母
function isWordbig(word){
	if(!(/^[A-Z]+$/.test(word))) return "请输入正确的姓氏首字母";
	return true;
}
//校验身份证号码
function isCardNumber(word){
	if(!(/\d{15}|\d{17}[0-9Xx]/.test(word))) return "请输入正确的身份证号码";
	return true;
}
$(document).ready(function(){
	$("#birthday").blur( function () { 
		if($("#birthday").val().length!=0){
			var birthYear = parseInt($("#birthday").val().substring(0,4)); 
			if(birthYear<=1900 || birthYear >=2017){
				$("#birth_reminder").html("生日年份输入不合法，请重新输入！");
				$("#age").val("");
				$("#birth_reminder").css("color","red");
				$("#birthday").focus();
				return false;
			}else{
				$("#birth_reminder").html("请按规范输入生日：1978-03-18（年份必填！）");
				$("#birth_reminder").css("color","#959595");
				var nowDate = new Date();
				var nowYear = parseInt(nowDate.getFullYear());
				var age = nowYear - birthYear;
				$("#age").val(age); 
			}
		}
	});
	$.formValidator.initConfig({formid:"myform",autotip:true,onerror:function(msg,obj){window.top.art.dialog({content:msg,lock:true,width:'220',height:'70'}, function(){this.close();$(obj).focus();})}});
	$('#realname').formValidator({autotip:true,onshow:"<?php echo L('please_input_student_realname')?>",onfocus:"<?php echo L('please_input_student_realname')?>",oncorrect:"<?php echo L('right')?>"}).inputValidator({min:1,onerror:"<?php echo L('please_input_student_realname')?>"}).functionValidator({fun:isRealname});
	$('#email').formValidator({
    	autotip:false,
    	onshow:'<?php echo L('please_input_email')?>',
        empty:true}).functionValidator({fun:isEmail});
    $('#identification').formValidator({
    	autotip:false,
    	onshow:'<?php echo L('please_input_identification')?>',onfocus:"<?php echo L('please_input_identification')?>",oncorrect:"<?php echo L('right')?>"}).inputValidator({min:18,onerror:"<?php echo L('please_input_identification')?>"}).functionValidator({fun:isCardNumber});
    $('#letter').formValidator({
		autotip:true,
		onshow:"<?php echo L('please_input_moter_letter')?>",
		onfocus:"<?php echo L('please_input_moter_letter')?>",
		oncorrect:"<?php echo L('right')?>"}).inputValidator({
			min:1,onerror:"<?php echo L('please_input_moter_letter')?>"
		}).functionValidator({fun:isWordbig});
});
</script>